package com.meilingcloud.activiti.domain.dto;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.meilingcloud.common.core.domain.BaseEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.activiti.api.task.model.Task;
import org.activiti.engine.runtime.ProcessInstance;

import java.util.Date;

@Data
@EqualsAndHashCode(callSuper = true)
public class ActTaskDto extends BaseEntity {

    private static final long serialVersionUID = 1L;

    private String id;

    private String name;

    private String status;

    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date createTime;

    private String instanceName;

    private String definitionKey;

    private String businessKey;

    public ActTaskDto() {

    }

    public ActTaskDto(Task task, ProcessInstance processInstance) {
        this.id = task.getId();
        this.name = task.getName();
        this.status = task.getStatus().toString();
        this.createTime = task.getCreatedDate();
        this.instanceName = processInstance.getName();
        this.definitionKey = processInstance.getProcessDefinitionKey();
        this.businessKey = processInstance.getBusinessKey();
    }

}
